# coding:utf-8


'''

继承

- 子类拥有父类所有的属性和方法
- 父类不具备子类自有的属性和方法

class Parent(object):
    ....
class Child(parent):
    ....

- 定义子类时，将父类传入子类参数内
- 子类实例化可以调用自己与父类的函数与变量
- 父类无法调用子类的函数与变量

'''

class Parent(object):
    def __init__(self,name,age):
        self.name = name
        self.age = age

    def talk(self):
        return f'{self.name} are walking'

    def is_sex(self):
        if self.age <= 10:
            return f'{self.name} is child'
        else:
            return f'{self.name} is adult'

class ChildOne(Parent):
    def play_football(self):
        return f'{self.name} are playing football'

class ChildTwo(Parent):
    def play_pingpong(self):
        return f'{self.name} are playing pingpong'


c_one = ChildOne("fan",10)
print(c_one.play_football())
print(c_one.talk())
print(c_one.is_sex())
c_two = ChildTwo("lihao",20)
print(c_two.play_pingpong())
print(c_two.talk())
print(c_two.is_sex())

